import request from '../utils/request';

export function login(userInfo) {
  console.log('user info: ', userInfo);
  return request({
    method: 'post',
    url: '/v1/auth/login',
    data: userInfo
  });
}
// 获取消息列表
export const getMessList = (params, token) =>
  request({
    method: 'get',
    url: '/v1/message/selectModuleMsg',
    params: params,
    headers: {
      token
    }
  });

// 获取消息详情
export const getMessDetail = (params, token) =>
  request({
    method: 'get',
    url: '/v1/message/selectMessageList',
    params: params,
    headers: {
      token
    }
  });

export function logout() {
  return request({
    method: 'post',
    url: '/v1/auth/logout'
  });
}

export function fetchUserInfo(token) {
  return request({
    method: 'get',
    url: '/v1/auth/user',
    headers: {
      token
    }
  });
}

// get alarm type
export function fetchAlarmType(token, orgCode) {
  return request({
    method: 'get',
    url: `/v1/alarm/loadAlarmType/${orgCode}`,
    headers: {
      token
    }
  });
}

// 获取类型描述
export function fetchAlarmTypeDesc(token, typeId) {
  return request({
    method: 'get',
    url: `/v1/alarm/loadAlarmTypeDesc/${typeId}`,
    headers: {
      token
    }
  });
}

// 开始报警
export function startAlarm(token, record) {
  return request({
    method: 'post',
    url: '/v1/alarm/addAlarm',
    headers: {
      token
    },
    data: record
  });
}

export function getRecordList(token, params) {
  return request({
    method: 'get',
    params: params,
    url: '/v1/policeMovement/policeMovementRecord/list',
    headers: {
      token
    }
  });
}

export function queryByDept(token, params) {
  return request({
    method: 'get',
    params: params,
    url: '/v1/policeMovement/policeMovementRecord/queryByDept',
    headers: {
      token
    }
  });
}

export function queryByPoliceCode(token) {
  return request({
    method: 'get',
    url: '/v1/policeMovement/policeMovementRecord/queryByPoliceCode',
    headers: {
      token
    }
  });
}

export function queryByPoliceDept(token) {
  return request({
    method: 'get',
    url: '/v1/policeMovement/policeMovementRecord/queryByPoliceDept',
    headers: {
      token
    }
  });
}

export function addEduTalk(token, data) {
  return request({
    method: 'post',
    url: '/v1/educate/talk/add',
    headers: {
      token
    },
    data: data
  });
}

export function getDepList(token, code) {
  console.log(token, code);
  return request({
    method: 'get',
    url: '/v1/educate/talk/deptList',
    headers: {
      token
    },
    params: {
      sdtOrgCode: code
    }
  });
}

export function getDeptDetails(token, deptId) {
  return request({
    method: 'get',
    url: `/v1/educate/talk/eduAll/${deptId}`,
    headers: {
      token
    },
    params: {
      deptId
    }
  });
}
//新增日志
export function addWorkDiary(token, dto) {
  return request({
    method: 'post',
    data: dto,
    url: 'v1/policeWorkLog/add',
    headers: {
      token
    }
  });
}
//查询日志
export function queryByContent(token, params) {
  return request({
    method: 'get',
    params: params,
    url: 'v1/policeWorkLog/queryByContent',
    headers: {
      token
    }
  });
}
//查询提交日志人数
export function queryByCount(token) {
  return request({
    method: 'get',
    url: 'v1/policeWorkLog/queryByCount',
    headers: {
      token
    }
  });
}

//根据日期查询释放罪犯
export function queryByRelease(token, params) {
  return request({
    method: 'get',
    params: params,
    url: '/v1/prisonerRelease/queryByRelease',
    headers: {
      token
    }
  });
}

//根据日期查询释放罪犯人数
export function queryPrisonByCount(token, params) {
  return request({
    method: 'get',
    params: params,
    url: '/v1/prisonerRelease/queryByCount',
    headers: {
      token
    }
  });
}

export function applyTalkHistoryList(
  token,
  pageSize,
  pageNum,
  deptId,
  petCreateTime
) {
  return request({
    method: 'get',
    url: '/v1/educate/talk/deptEduList',
    headers: {
      token
    },
    params: {
      deptId,
      petCreateTime,
      pageSize,
      pageNum
    }
  });
}
